package com.company.project.service.impl;

import com.company.project.dao.LeagueMapper;
import com.company.project.model.League;
import com.company.project.service.LeagueService;
import com.company.project.core.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


/**
 * Created by CodeGenerator on 2018/10/08.
 */
@Service
@Transactional
public class LeagueServiceImpl extends AbstractService<League> implements LeagueService {
    @Resource
    private LeagueMapper leagueMapper;
    /**
     * 查询期刊加盟
     * @return
     */
    @Override
    public List<League> selectLeague() {
        return leagueMapper.selectLeague();
    }

    @Override
    public Boolean updateleague(League league) {
        if(this.selectLeague().size()>0){
            Boolean updateleague = leagueMapper.updateleague(league);
            return updateleague;
        }else {
            int insert = leagueMapper.insertLeague(league);
            if (insert>0){
                return true;
            }else {
                return false;
            }
        }
    }

    @Override
    public int insertLeague(League league) {
        return leagueMapper.insertLeague(league);
    }
}

